\hypertarget{udd_8h}{
\section{udd.h \-File \-Reference}
\label{udd_8h}\index{udd.\-h@{udd.\-h}}
}


\-Common \-A\-P\-I for \-U\-S\-B \-Device \-Drivers (\-U\-D\-D)  


{\ttfamily \#include \char`\"{}usb\-\_\-protocol.\-h\char`\"{}}\*
{\ttfamily \#include \char`\"{}udc\-\_\-desc.\-h\char`\"{}}\*
\subsection*{\-Data \-Structures}
\begin{DoxyCompactItemize}
\item 
struct \hyperlink{structudd__setup__req__t}{udd\-\_\-setup\-\_\-req\-\_\-t}
\item 
struct \hyperlink{structudd__ctrl__request__t}{udd\-\_\-ctrl\-\_\-request\-\_\-t}
\begin{DoxyCompactList}\small\item\em \-Global variable to give and record information of the setup request management. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{\-Defines}
\begin{DoxyCompactItemize}
\item 
\#define \hyperlink{group__udd__group_gaffd9b7cf165cd149868373fa12595d12}{\-Udd\-\_\-setup\-\_\-is\-\_\-in}()~(\-U\-S\-B\-\_\-\-R\-E\-Q\-\_\-\-D\-I\-R\-\_\-\-I\-N == (udd\-\_\-g\-\_\-ctrlreq.\-req.\-bm\-Request\-Type \& \-U\-S\-B\-\_\-\-R\-E\-Q\-\_\-\-D\-I\-R\-\_\-\-M\-A\-S\-K))
\begin{DoxyCompactList}\small\item\em \-Return true if the setup request {\itshape udd\-\_\-g\-\_\-ctrlreq\/} indicates \-I\-N data transfer. \end{DoxyCompactList}\item 
\#define \hyperlink{group__udd__group_gaf67b7c8de30fdc881b567385f2345926}{\-Udd\-\_\-setup\-\_\-is\-\_\-out}()~(\-U\-S\-B\-\_\-\-R\-E\-Q\-\_\-\-D\-I\-R\-\_\-\-O\-U\-T == (udd\-\_\-g\-\_\-ctrlreq.\-req.\-bm\-Request\-Type \& \-U\-S\-B\-\_\-\-R\-E\-Q\-\_\-\-D\-I\-R\-\_\-\-M\-A\-S\-K))
\begin{DoxyCompactList}\small\item\em \-Return true if the setup request {\itshape udd\-\_\-g\-\_\-ctrlreq\/} indicates \-O\-U\-T data transfer. \end{DoxyCompactList}\item 
\#define \hyperlink{group__udd__group_ga85dc2b7b6c270e8dd8323fa4779a7ca2}{\-Udd\-\_\-setup\-\_\-type}()~(udd\-\_\-g\-\_\-ctrlreq.\-req.\-bm\-Request\-Type \& \-U\-S\-B\-\_\-\-R\-E\-Q\-\_\-\-T\-Y\-P\-E\-\_\-\-M\-A\-S\-K)
\begin{DoxyCompactList}\small\item\em \-Return the type of the \-S\-E\-T\-U\-P request {\itshape udd\-\_\-g\-\_\-ctrlreq\/}. \end{DoxyCompactList}\item 
\#define \hyperlink{group__udd__group_gac963bb7b8a965c2fec45a71c9faca6f5}{\-Udd\-\_\-setup\-\_\-recipient}()~(udd\-\_\-g\-\_\-ctrlreq.\-req.\-bm\-Request\-Type \& \-U\-S\-B\-\_\-\-R\-E\-Q\-\_\-\-R\-E\-C\-I\-P\-\_\-\-M\-A\-S\-K)
\begin{DoxyCompactList}\small\item\em \-Return the recipient of the \-S\-E\-T\-U\-P request {\itshape udd\-\_\-g\-\_\-ctrlreq\/}. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{\-Typedefs}
\begin{DoxyCompactItemize}
\item 
typedef uint8\-\_\-t \hyperlink{group__udd__group_ga6f25ea016c07bd48c3074f51d8ef8b01}{udd\-\_\-ep\-\_\-id\-\_\-t}
\begin{DoxyCompactList}\small\item\em \-Endpoint identifier. \end{DoxyCompactList}\item 
typedef void($\ast$ \hyperlink{group__udd__group_ga7ab8d43f0761ecfb4d48770ac4ebb661}{udd\-\_\-callback\-\_\-halt\-\_\-cleared\-\_\-t} )(void)
\begin{DoxyCompactList}\small\item\em \-End of halt callback function type. \-Registered by routine udd\-\_\-ep\-\_\-wait\-\_\-stall\-\_\-clear() \-Callback called when endpoint stall is cleared. \end{DoxyCompactList}\item 
typedef void($\ast$ \hyperlink{group__udd__group_gad866ed9444482edcf92a28dce807e3d3}{udd\-\_\-callback\-\_\-trans\-\_\-t} )(\hyperlink{group__udd__group_gac0f77f5a0e085af1242b48fd1054959a}{udd\-\_\-ep\-\_\-status\-\_\-t} status, iram\-\_\-size\-\_\-t nb\-\_\-transfered)
\begin{DoxyCompactList}\small\item\em \-End of transfer callback function type. \-Registered by routine udd\-\_\-ep\-\_\-run() \-Callback called by \-U\-S\-B interrupt after data transfer or abort (reset,...). \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{\-Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \hyperlink{group__udd__group_gac0f77f5a0e085af1242b48fd1054959a}{udd\-\_\-ep\-\_\-status\-\_\-t} \{ \hyperlink{group__udd__group_ggac0f77f5a0e085af1242b48fd1054959aad52bb23180c67dc3d6a1d1dfedf74102}{\-U\-D\-D\-\_\-\-E\-P\-\_\-\-T\-R\-A\-N\-S\-F\-E\-R\-\_\-\-O\-K} =  0, 
\hyperlink{group__udd__group_ggac0f77f5a0e085af1242b48fd1054959aa010443246cb439e4f6f52b13c9d6e29c}{\-U\-D\-D\-\_\-\-E\-P\-\_\-\-T\-R\-A\-N\-S\-F\-E\-R\-\_\-\-A\-B\-O\-R\-T} =  1
 \}
\begin{DoxyCompactList}\small\item\em \-Endpoint transfer status \-Returned in parameters of callback register via udd\-\_\-ep\-\_\-run routine. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{\-Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{group__udd__group_ga14096700b3ed8c5168615c5c5ee1c68d}{\-C\-O\-M\-P\-I\-L\-E\-R\-\_\-\-P\-A\-C\-K\-\_\-\-S\-E\-T} (1)
\begin{DoxyCompactList}\small\item\em \-A \-U\-S\-B \-Device \-S\-E\-T\-U\-P request. \end{DoxyCompactList}\item 
\hyperlink{group__udd__group_gabe317a1520896eaf568afab27dc71540}{\-C\-O\-M\-P\-I\-L\-E\-R\-\_\-\-P\-A\-C\-K\-\_\-\-R\-E\-S\-E\-T} ()
\end{DoxyCompactItemize}
\begin{Indent}\paragraph*{\-Management of bulk/interrupt/isochronous endpoints}
{\em \-Buffer to store the data received on control endpoint (\-S\-E\-T\-U\-P/\-O\-U\-T endpoint 0)

\-Used to avoid a \-R\-A\-M buffer overflow in case of the payload buffer is smaller than control endpoint size

\-The \-U\-D\-D manages the data transfer on endpoints\-:
\begin{DoxyItemize}
\item \-Start data tranfer on endpoint with \-U\-S\-B \-Device \-D\-M\-A
\item \-Send a \-Z\-L\-P packet if requested
\item \-Call callback registered to signal end of transfer \-The transfer abort and stall feature are supported. 
\end{DoxyItemize}}\begin{DoxyCompactItemize}
\item 
bool \hyperlink{group__udd__group_gaa4cac8c35ae056e26cf4ab5b426bbe09}{udd\-\_\-include\-\_\-vbus\-\_\-monitoring} (void)
\begin{DoxyCompactList}\small\item\em \-Authorizes the \-V\-B\-U\-S event. \end{DoxyCompactList}\item 
void \hyperlink{group__udd__group_ga9792d1899ae058e3984d6a622fe2ad42}{udd\-\_\-enable} (void)
\begin{DoxyCompactList}\small\item\em \-Enables the \-U\-S\-B \-Device mode. \end{DoxyCompactList}\item 
void \hyperlink{group__udd__group_gab283432057b934e9d73ac9282d9b0f11}{udd\-\_\-disable} (void)
\begin{DoxyCompactList}\small\item\em \-Disables the \-U\-S\-B \-Device mode. \end{DoxyCompactList}\item 
void \hyperlink{group__udd__group_ga7a7c0d9236c922c2af33c6702565a99f}{udd\-\_\-attach} (void)
\begin{DoxyCompactList}\small\item\em \-Attach device to the bus when possible. \end{DoxyCompactList}\item 
void \hyperlink{group__udd__group_ga03e59eaa264f1dbe5a52559311d0520e}{udd\-\_\-detach} (void)
\begin{DoxyCompactList}\small\item\em \-Detaches the device from the bus. \end{DoxyCompactList}\item 
bool \hyperlink{group__udd__group_ga85f403ddb78776b1ba014dafd3ffec2c}{udd\-\_\-is\-\_\-high\-\_\-speed} (void)
\begin{DoxyCompactList}\small\item\em \-Test whether the \-U\-S\-B \-Device \-Controller is running at high speed or not. \end{DoxyCompactList}\item 
void \hyperlink{group__udd__group_ga05da762e0faf9d478e532de40afa71f6}{udd\-\_\-set\-\_\-address} (uint8\-\_\-t address)
\begin{DoxyCompactList}\small\item\em \-Changes the \-U\-S\-B address of device. \end{DoxyCompactList}\item 
uint8\-\_\-t \hyperlink{group__udd__group_gaebd36638d482f6df00a8aff006ef2246}{udd\-\_\-getaddress} (void)
\begin{DoxyCompactList}\small\item\em \-Returns the \-U\-S\-B address of device. \end{DoxyCompactList}\item 
uint16\-\_\-t \hyperlink{group__udd__group_ga96dc248cc05e07ffe2cf21e4d7465320}{udd\-\_\-get\-\_\-frame\-\_\-number} (void)
\begin{DoxyCompactList}\small\item\em \-Returns the current start of frame number. \end{DoxyCompactList}\item 
uint16\-\_\-t \hyperlink{group__udd__group_ga63047eec59b8e8798ca1d3366472d82b}{udd\-\_\-get\-\_\-micro\-\_\-frame\-\_\-number} (void)
\begin{DoxyCompactList}\small\item\em \-Returns the current micro start of frame number. \end{DoxyCompactList}\item 
void \hyperlink{group__udd__group_ga14ae6068206556d6ae8766b1baa2f686}{udd\-\_\-send\-\_\-wake\-\_\-up} (void)
\begin{DoxyCompactList}\small\item\em \-The \-U\-S\-B driver sends a resume signal called \-Upstream \-Resume. \end{DoxyCompactList}\item 
void \hyperlink{group__udd__group_ga017ef5ea7626be258c24d345218976f9}{udd\-\_\-set\-\_\-setup\-\_\-payload} (uint8\-\_\-t $\ast$payload, uint16\-\_\-t payload\-\_\-size)
\begin{DoxyCompactList}\small\item\em \-Load setup payload. \end{DoxyCompactList}\end{DoxyCompactItemize}
\end{Indent}
\begin{Indent}\paragraph*{\-High speed test mode management}
{\em \-The following functions allow the device to jump to a specific test mode required in high speed mode. }\begin{DoxyCompactItemize}
\item 
void \hyperlink{group__udd__group_ga43ba1e91e69f84c1481a659ff8eff143}{udd\-\_\-test\-\_\-mode\-\_\-j} (void)
\item 
void \hyperlink{group__udd__group_ga2acd547bcd2b470ee4e1ce34087926a8}{udd\-\_\-test\-\_\-mode\-\_\-k} (void)
\item 
void \hyperlink{group__udd__group_gabec7e8b6464e92ca9c8f32c59113bcbb}{udd\-\_\-test\-\_\-mode\-\_\-se0\-\_\-nak} (void)
\item 
void \hyperlink{group__udd__group_gab72f68f8d1a50f7e734595a2ff626380}{udd\-\_\-test\-\_\-mode\-\_\-packet} (void)
\end{DoxyCompactItemize}
\end{Indent}
\begin{Indent}\paragraph*{\-U\-D\-C callbacks to provide for \-U\-D\-D}
{\em \-The following callbacks are used by \-U\-D\-D. }\begin{DoxyCompactItemize}
\item 
bool \hyperlink{group__udd__group_ga58c2916d7984e0e5b2143cadf4af6080}{udc\-\_\-process\-\_\-setup} (void)
\begin{DoxyCompactList}\small\item\em \-Decodes and manages a setup request. \end{DoxyCompactList}\item 
void \hyperlink{group__udd__group_ga11a32ff7928ba06d3b59e95e0a2b7a92}{udc\-\_\-reset} (void)
\begin{DoxyCompactList}\small\item\em \-Reset the \-U\-D\-C. \end{DoxyCompactList}\item 
void \hyperlink{group__udd__group_ga4afae313045f44b5eb4c60957ab8ef4e}{udc\-\_\-sof\-\_\-notify} (void)
\begin{DoxyCompactList}\small\item\em \-To signal that a \-S\-O\-F is occured. \end{DoxyCompactList}\end{DoxyCompactItemize}
\end{Indent}
\subsection*{\-Variables}
\begin{DoxyCompactItemize}
\item 
\hyperlink{structudd__ctrl__request__t}{udd\-\_\-ctrl\-\_\-request\-\_\-t} \hyperlink{group__udd__group_ga360872da67c7f8ecebe1238bbd4a536e}{udd\-\_\-g\-\_\-ctrlreq}
\begin{DoxyCompactList}\small\item\em \-Global variable to give and record information about setup request management. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{\-Detailed \-Description}
\-Common \-A\-P\-I for \-U\-S\-B \-Device \-Drivers (\-U\-D\-D) \-Copyright (\-C) 2009 \-Atmel \-Corporation. \-All rights reserved. 